package com.itheima.concorrent;

import java.util.HashMap;

public class Demo01 {

    public static void main(String[] args) throws InterruptedException {
        HashMap<String, String> map = new HashMap<>();

        //开启两条线程 向map中添加数据

        new Thread(()->{
            for (int i = 1; i <= 50; i++) {
                map.put(i+"",i+"");

            }
        }).start();
        new Thread(()->{
            for (int i = 51; i <= 100; i++) {
                map.put(i+"",i+"");

            }
        }).start();
        new Thread(()->{
            for (int i = 101; i <= 200; i++) {
                map.put(i+"",i+"");

            }
        }).start();
        new Thread(()->{
            for (int i = 201; i <= 400; i++) {
                map.put(i+"",i+"");

            }
        }).start();
        // map 长度是100  内部有100个键值对   1=1 2=2...100=100

        Thread.sleep(2000);

        for (int i = 1; i <= 400; i++) {
            System.out.println(map.get(i+""));
        }



    }
}
